package com.bjsxt.collection;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class IteratorListTest {
    public static void main(String[] args){
        List<String> list =new ArrayList<>();
        list.add("aa");
        list.add("bb");
        list.add("cc");

        Iterator<String> iterator =list.iterator();
        boolean flag=iterator.hasNext();
        while (flag){
                    String value = iterator.next();
                    System.out.println(value);
                    flag = iterator.hasNext();
    }

    for (Iterator<String> it =list.iterator();it.hasNext();){
        String value = it.next();
        System.out.println(value);
    }

    }
}
